﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

using LINQToolKit.Douban.Entities;
using LINQToolKit;
using LINQToolKit.Processors;
using LINQToolKit.Mapping;

namespace  LINQToolKit.Douban.Processors
{
    public sealed class RatingProcessor : PropertyProcessor
    {
        public override object FromXml(MetaProperty meta, IEnumerable<XElement> elements)
        {
            var e = elements.First();

            return new Rating
            {
                Min = e.Attribute("min").GetInt(),
                Max = e.Attribute("max").GetInt(),
                Average = e.Attribute("average").GetDecimal(),
                Value = e.Attribute("value").GetInt(),
                NumberOfRaters = e.Attribute("numRaters").GetInt()
            };
        }
    }
}
